require 'config/boot'
require 'config/environment'
require 'set'
require 'lib/simple-json'

task :select_item do
  list = Hash.new
  @pos = Segment.find(:all,:select => "part_of_speech",:group => "part_of_speech")
  list["part_of_speech"] = @pos.map{|segment| segment.part_of_speech }
  @ctype_cform = Hash.new{|hash,key| hash[key] = Set.new}
  Segment.find(:all,:select => "ctype,cform",:group => "ctype,cfrom").each{|segment|
    @ctype_cform[segment.ctype] << segment.cfrom
  }
  list["ctype_cform"] = @ctype_cform
  puts JsonBuilder.new.build(list)
end